
version 17.0
clear
********Trade Openness, Job Sectors, and Social Policy Preferences: Evidence from China********
**************************Manuscript for PSRM*****************
**********************Authors: Li Zheng and Ling Zhu****************

use "Data.dta", clear
set scheme s1mono	
graph set window fontface "GillSans"	// turns default graph font into GillSans

//////////////////////////////////////////////////////////
/////////////   MAIN RESULTS AND FIGURES  ///////////////
////////////////////////////////////////////////////////

** Trade and Protection in  Table A2 

gllamm Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt

gllamm Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt 

** Exports / Imports and Protection in Table A3

gllamm Govresp Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256)link(ologit) adapt

gllamm Unemploy Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V25)link(ologit) adapt


** Trade, Job Sectors, and Social Protection in Table A4

gen interaction=Tradelib*Private

ologit Govresp Tradelib Private interaction unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

ologit Unemploy Tradelib Private interaction unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)


**Figure 1, Table A2

quietly gllamm Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt
estimate store g
quietly gllamm Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt 
estimate store u

set scheme s2mono

coefplot (g, label (Government)) (u, label (Unemploy)), drop (_cons Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP) eform xscale(log) xline (1) ciopts(recast(rcap)) graphregion(color(white)) bgcolor(white) saving (Figure1a.gph)

coefplot (g, label (Government)) (u, label (Unemploy)), drop (_cons Tradelib unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP) eform xscale(log) xline (1) ciopts(recast(rcap)) graphregion(color(white)) bgcolor(white) saving (Figure1b.gph)

gr combine Figure1a.gph  Figure1b.gph, saving(Figure1.gph)

**Export and Import: Figure 2, Table A3 

quietly gllamm Govresp Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt
estimate store g1

quietly gllamm Unemploy Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt
estimate store u1

set scheme s2mono
coefplot (g1, label (Government)) (u1, label (Unemploy)), drop (_cons Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP) eform xscale(log) xline (1) ciopts(recast(rcap)) graphregion(color(white)) bgcolor(white) saving (Figure2a.gph)

coefplot (g1, label (Government)) (u1, label (Unemploy)), drop (_cons Exportlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP) eform xscale(log) xline (1) ciopts(recast(rcap)) graphregion(color(white)) bgcolor(white) saving (Figure2b.gph)

gr combine Figure2a.gph  Figure2b.gph, saving(Figure2.gph)


** Interflex for Figure 3, Table A4

interflex Govresp Private Tradelib unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, vce(boot) reps(1500) ylab (Gov Role) dlab(Private Employee) xlab(Trade Openness-Province) type(linear) saving(Figure3)

** Interflex for Figure 4, Table A4

interflex Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, vce(boot) reps(1500) ylab (Gov Role) dlab(Trade Openness-Province) xlab(Private Employee) type(linear) saving(Figure4)

**DV visuals in Figure A1 of the statistical appendix

set scheme s2mono
hist Govresp, percent normal addlabels addlabopts(yvarformat(%4.2f)) ylabel(0(10)20, grid) xlabel(1(1)10) graphregion(color(white)) bgcolor(white) scheme(s2mono) saving(FigureA1a)
hist Unemploy, percent normal addlabels addlabopts(yvarformat(%4.2f)) ylabel(0(10)30, grid) xlabel(1(1)10) graphregion(color(white)) bgcolor(white) scheme(s2mono) saving (FigureA1b)

gr combine FigureA1a.gph  FigureA1b.gph, saving(FigureA1) 


**Trade visual in Figure A2 of the statistical appendix is provided separately by using R codes



//////////////////////////////////////////////////////////
/////////////   APPENDIX  ///////////////////////////////
////////////////////////////////////////////////////////

** Summary of statistics, Table A1

sum Govresp Unemploy Tradelib Exportlib Importlib Private unemployment Income FDIlib Tertiaryindustry employed Age Education Skill Female EqualityP


**Response rate, Table A5, Table A6

recode Govresp (1/10=1) (.=0), generate (gov_rate)
recode Unemploy (1/10=1) (.=0), generate (un_rate)

label variable gov_rate "Govt Response" 
label variable un_rate "Unemploy Response"

logit gov_rate Tradelib Private unemployment Education Female Income employed Age EqualityP, robust 
logit un_rate Tradelib Private unemployment Education Female Income employed Age EqualityP, robust

logit gov_rate Tradelib Private unemployment Education Female Income employed Age EqualityP, robust or 
logit un_rate Tradelib Private unemployment Education Female Income employed Age EqualityP, robust or

**Ologit with cluster standard error, Table A7, A8

ologit Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

ologit Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

ologit Govresp Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

ologit Unemploy Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

**Ologit with province-level fixed effect, Table A9

xi: ologit Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP i.V256, cluster(V256)

xi: ologit Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP i.V256, cluster(V256)

**Controlling labor union and party membership, Table A10, A11

ologit Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, cluster(V256)

ologit Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, cluster(V256)

ologit Govresp Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, cluster(V256)

ologit Unemploy Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, cluster(V256)

gllamm Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, i(V256) link(ologit) adapt

gllamm Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, i(V256) link(ologit) adapt 

gllamm Govresp Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, i(V256) link(ologit) adapt

gllamm Unemploy Exportlib Importlib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP LaborMember PartyMember, i(V256) link(ologit) adapt 


**Trade as Lagged Variable and Economic Shocks, Table A12 

gen Tradechange= (Tradelib-tradelib)/tradelib
label variable Tradechange "Trade Change Rate" 


ologit Govresp tradelib Tradechange Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)

ologit Unemploy tradelib Tradechange Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, cluster(V256)


gllamm Govresp tradelib Tradechange Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt

gllamm Unemploy tradelib Tradechange Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age EqualityP, i(V256) link(ologit) adapt 


**Interaction: skill and trade openness, Table A13

gen interaction1=Tradelib*Skill

gllamm Govresp Tradelib Skill interaction1 Private unemployment FDIlib Tertiaryindustry Income employed Female Education Age EqualityP, i(V256) link(ologit) adapt 

gllamm Unemploy Tradelib Skill interaction1 Private unemployment FDIlib Tertiaryindustry Income employed Female Education Age EqualityP, i(V256) link(ologit) adapt

**Replace perceived inequality with province-level Gini, Table A14

gllamm Govresp Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age GINI, i(V256) link(ologit) adapt

gllamm Unemploy Tradelib Private unemployment FDIlib Tertiaryindustry Income employed Female Education Skill Age GINI, i(V256) link(ologit) adapt 

